package com.syl.practice.configuration.controller;

import com.syl.practice.configuration.pojo.Animal;
import com.syl.practice.configuration.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/config")
public class MyConfigController {

    // 按名称注入
    @Resource(name = "book1")
    Book book;

    // 按类型注入
    @Autowired
    Animal animal;

    @RequestMapping("/test")
    public void test(){
        System.out.println(book.getAuthor());
        System.out.println(book.getName());

        System.out.println(animal.getName());
        System.out.println(animal.getType());
    }
}
